#include <stdio.h>
int main()
{
	int arr1[] = { 1,2,3,4,5,6,7,8,9 };
	int left = 0;
	int right = sizeof(arr1)/sizeof(arr1[0]) - 1;
	int key = 5;
	int mid = 0;
	while(left<=right)
{
		mid = left + (right - left) / 2;

	if (arr1[mid] > key)
	{
	right = mid-1;
	}
	else if (arr1[mid] < key)
	{
	left = mid+1;
	}
	else
	{
		break;
	}
}
	printf("%d\n", mid);
}